﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace DomExplorer
{
    class StyleMainpulation
    {
        public int PreviousIndex
        {
            get;
            set;
        }

        public int CurrentIndex
        {
            get;
            set;
        }

        public string PreviousStyle
        {
            get;
            set;
        }

        public string CurrentStyle
        {
            get;
            set;
        }

        private HtmlElement m_LastElement;


        public void SetElementStyle(HtmlElement theElement)
        {
            /** Load the default style...i think its a blue box **/
            //

            /** scroll image to top **/
            theElement.ScrollIntoView(true);

            if (PreviousIndex != CurrentIndex)
            {
                //theElement.Style = CurrentStyle;
                if (PreviousStyle == null)
                {
                    PreviousStyle = string.Empty;
                }

            }

            if (m_LastElement == null)
            {
                m_LastElement = theElement;

            }
            m_LastElement.Style = PreviousStyle;
            theElement.Style = CurrentStyle;
            PreviousIndex = CurrentIndex;
            m_LastElement = theElement;
        }

        public void SetElementStyle(HtmlElementCollection coll, int index)
        {

            HtmlElement theElement = coll[index];

            /** scroll image to top **/
            theElement.ScrollIntoView(true);

            if (PreviousIndex != CurrentIndex)
            {
                //theElement.Style = CurrentStyle;
                if (PreviousStyle == null)
                {
                    PreviousStyle = string.Empty;
                }

            }

            if (m_LastElement == null)
            {
                m_LastElement = theElement;

            }
            m_LastElement.Style = PreviousStyle;
            theElement.Style = CurrentStyle;
            PreviousIndex = CurrentIndex;
            m_LastElement = theElement;

        }
    }
}
